<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php 
	if( !isset($_COOKIE["username"]) ){
		echo "<script>window.location.href='login.php'</script>";
	}else{
		setcookie("username", $_COOKIE["username"],time() + 900);
	}
?>
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>List Unprinted Report</title>
<link href="css/template.css" rel="stylesheet" type="text/css" />
<script src="js/droplinemenu.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>

<link href="css/ui-lightness/jquery-ui-1.9.2.custom.css" rel="stylesheet">
<script src="js/jquery-1.8.3.js"></script>
<script src="js/jquery-ui-1.9.2.custom.js"></script>

<script type="text/javascript">
	droplinemenu.buildmenu("nav");

</script>


</head>

<body>
	<div id="container">
		<div id="header"></div>
		<?php include_once 'nav.php';?>
		<?php 
			$ini_array = parse_ini_file("config/config.ini");
		
			date_default_timezone_set($ini_array["default_timezone"]);	
		

			$conn = @mysqli_connect($ini_array["host"], $ini_array["username"], $ini_array["password"], $ini_array["db_name"]) or die("cann't connect the ");
			mysqli_set_charset($conn, "utf8");
			ini_set('default_charset', "UTF-8");
			date_default_timezone_set($ini_array["default_timezone"]);

				
			
			$getReportInfoSql = "SELECT Appointment_no, patient.`First_name`, patient.`Surname`, doctor.`doctor_first_name`, doctor.`doctor_surname`, visit.`Datetime_patient_seen`, clinic.`Clinic_name` FROM visit LEFT OUTER JOIN patient ON patient.`Patient_no`=visit.`Patient_no` LEFT OUTER JOIN clinic ON visit.`Clinic_no`=clinic.`Clinic_no` LEFT OUTER JOIN doctor ON patient.`doctor_no`=doctor.`Doctor_no` WHERE visit.`is_printed`=0";
			$reportResult = mysqli_query($conn, $getReportInfoSql);
		
			
		?>
		<div id="main_content" style="text-align:center">
			<div id="title"><h2>List Unprinted Report</h2></div>
			<div style="width:150px;display:inline-block;"><label>Appointment No.</label></div>
			<div style="width:150px;display:inline-block;"><label>Patient Name</label></div>
			<div style="width:140px;display:inline-block"><label>Doctor Name</label></div>
			<div style="width:320px;display:inline-block"><label>Clinic Name</label></div>
			<div style="width:150px;display:inline-block"><label>Seen Datetime</label></div>
			<div style="width:150px;display:inline-block"><label>go to</label></div>
			<div id="appointmentList" style="max-height:600px;overflow:auto;width:1120px;margin:0px auto;">
				<table style="width:1100px">
					<?php 
						while( $row = mysqli_fetch_array($reportResult)){
							$appointmentNo = $row["Appointment_no"];
							$patientName = $row["First_name"]."  ".$row["Surname"];
							$doctorName = $row["doctor_first_name"]."  ".$row["doctor_surname"];
							$seenDatetime = date("d/m/Y H:i", strtotime($row["Datetime_patient_seen"]));
							$clinicName = $row["Clinic_name"];
							
					?>
					<tr>
						<td width="6%"><?php echo $appointmentNo?></td>
						<td width="25%"><?php echo $patientName?></td>
						<td width="12%"><?php echo $doctorName?></td>
						<td width="30%"><?php echo $clinicName?></td>
						<td width="13%"><?php echo $seenDatetime?></td>
						<td width="10%"><a href="patient_report_pdf.php?appointmentNo=<?php echo $appointmentNo?>">go to print</a></td>
					</tr>
					<?php 
						}
					?>
				</table>
			</div>
			<input type="button" value="return" onclick="window.location.href='index.php'"/>
		</div>
		<?php include_once 'footer.php';?>
	</div>
</body>
</html>
